<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>碳中和在线监测系统</title>
    <link rel="stylesheet" href="css/index.css" />
    <link rel="stylesheet" href="css/mycss.css" />
    <script src="js/jquery.js"></script>
</head>

<body>
    <header>
        <div class="logout">
            <span
                style="color: white;font-size: 16px;float: left;line-height: 30px;margin-top: 10px;position: absolute;left: 5%;"
                class="username"></span>
            <a style="float: left;color: white;font-size: 16px;line-height: 30px;margin-top: 10px;cursor: pointer;position: absolute;left: 50%;"
                onclick="logout()" >退出</a>
        </div>

        <div class="header_navigate" style="left: 11%;">
            <ul>
                <li onclick="changePage('tanzhonghe')"
                    style="left: 6%;top: 50%;text-align: center;line-height: 50px;padding-right: 25px;font-size: 18px;"
                    class="nl_li">碳中和进程</li>
                <li class="tanpaifang nl_li"
                    style="left: 39%;top: 50%;text-align: center;line-height: 50px;padding-right: 25px;font-size: 18px;">
                    碳排放监测</li>

                <ul class="tanpaifang_dropdown">
                    <li style="border-bottom: 1px solid white;" onclick="toShebeiManage()">碳排放监测设备管理</li>
                    <li onclick="changePage('tanpaifang')">碳排放数据监测显示</li>
                </ul>
                <li class="nenghao nl_li"
                    style="left: 71%;top: 50%;text-align: center;line-height: 50px;padding-right: 25px;font-size: 18px;">
                    能耗监测</li>

                <ul class="tanpaifang_dropdown2">
                    <li style="border-bottom: 1px solid white;" onclick="changePage('all energy consumption')">所有能耗监测
                    </li>
                    <li onclick="changePage('single_equip')">单个设备的能耗监测</li>
                </ul>
            </ul>
        </div>


        <h2>
            <img src="https://lanhu.oss-cn-beijing.aliyuncs.com/SketchPng1eabf3fb64d0f5b4a2420c4ea5301ab347aec346620b1f147da14b55c799e105"
                alt="" srcset="" style="margin-top: 23px;float: left;">
            <span style="float: left;margin-left: 5px;">**集团碳中和在线监测系统</span>
        </h2>


        <div class="header_navigate nr" style="right: 11%;">
            <ul>
                <li onclick="changePage('nenghaojixiao')"
                    style="right: 70%;top: 50%;text-align: center;line-height: 50px">能耗绩效</li>
                <li onclick="changePage('chaobiaoyujing')"
                    style="right: 37%;top: 50%;text-align: center;line-height: 50px">超标预警</li>
                <li onclick="changePage('manager_index')"
                    style="right: 5%;top:50%;text-align: center;line-height: 50px;">系统管理</li>
            </ul>
        </div>
        <div class="showTime"></div>
        <script>
            var t = null;
            t = setTimeout(time, 1000); //開始运行
            function time() {
                clearTimeout(t); //清除定时器
                dt = new Date();
                var y = dt.getFullYear();
                var mt = dt.getMonth() + 1;
                var day = dt.getDate();
                var h = dt.getHours(); //获取时
                var m = dt.getMinutes(); //获取分
                var s = dt.getSeconds(); //获取秒
                document.querySelector(".showTime").innerHTML =
                    y +
                    "年" +
                    mt +
                    "月" +
                    day +
                    "日" +
                    h +
                    "时" +
                    m +
                    "分" +
                    s +
                    "秒";
                t = setTimeout(time, 1000); //设定定时器，循环运行
            }
        </script>

    </header>

    <iframe frameborder="0" class="main_content" src="http://127.0.0.1:5501/tanzhonghe.html" scrolling="no"></iframe>

    <script type="text/javascript">
        function changePage(name) {
            if (name === 'manager_index' && sessionStorage.getItem('id') != undefined) {
                $('.main_content').attr('src', 'http://127.0.0.1:5501/manager_index.html');
            } else {
                $('.main_content').attr('src', 'http://127.0.0.1:5501/' + name + '.html');
            }

        }

        function toShebeiManage() {
            $('.main_content').attr('src', 'https://www.thingjs.com/s/ea2d7b4dad32142277fdafa5');
        }

        function logout() {
            sessionStorage.removeItem('id');
            window.location.href = 'login.html';
        }

        $(document).ready(function () {
            console.log(sessionStorage.getItem('id'))
            if (sessionStorage.getItem('id') === null) {
                window.location.href = 'login.html';
            } else {

                $.ajax({
                    type: 'get',
                    url: 'http://localhost:8080/manage/selectOneById/' + sessionStorage.getItem('id'),
                    dataType: 'json',
                    success: function (data) {
                        if (data.code === 200) {
                            $('.username').text('欢迎您，' + data.data.manager.username)
                        }
                    }
                })

            }


            $('.tanpaifang').mouseover(function () {
                $('.tanpaifang_dropdown').css('display', 'inline');
            })

            $('.tanpaifang').mouseout(function () {
                $('.tanpaifang_dropdown').css('display', 'none');
            })

            $('.tanpaifang_dropdown').mouseenter(function () {
                $(this).css('display', 'inline')
            })

            $('.tanpaifang_dropdown').mouseleave(function () {
                $(this).css('display', 'none')
            })

            $('.nenghao').mouseover(function () {
                $('.tanpaifang_dropdown2').css('display', 'inline');
            })

            $('.nenghao').mouseout(function () {
                $('.tanpaifang_dropdown2').css('display', 'none');
            })

            $('.tanpaifang_dropdown2').mouseenter(function () {
                $(this).css('display', 'inline')
            })

            $('.tanpaifang_dropdown2').mouseleave(function () {
                $(this).css('display', 'none')
            })

        });


    </script>
</body>

</html>